﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace WebApplication1
{
    public partial class delpub : System.Web.UI.Page
    {
        SqlConnection cnn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True");

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                cnn.Open();
                SqlCommand cmd1 = new SqlCommand("select pbno from account", cnn);
                SqlDataReader dr1 = cmd1.ExecuteReader();
                DropDownList2.Items.Add("Select");
                while (dr1.Read())
                    DropDownList2.Items.Add(Convert.ToString(dr1.GetString(0)));
                cnn.Close();
            }
        }

        protected void delpbbtn_Click(object sender, EventArgs e)
        {
            string no = DropDownList2.SelectedValue;
            cnn.Open();
            SqlCommand cmd1 = new SqlCommand("delete from pub where pbno='" + no + "'", cnn);
            cnn.Close();
            Response.Redirect("default1.aspx");
        }
    }
}